package com.ys.ylideas.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ys.ylideas.dao.IdeaDao;
import com.ys.ylideas.entity.IdeaEntity;
import com.ys.ylideas.entity.IdeaHelp;
import com.ys.ylideas.service.IdeaService;

@Service("ideasService")
public class IdeaServiceImpl implements IdeaService {

	@Autowired
	private IdeaDao ideasDao;
	

	@Override
	public void save(IdeaEntity ideasEntity) {
		// TODO Auto-generated method stub
		ideasDao.save(ideasEntity);
	}

	@Override
	public void update(IdeaEntity ideasEntity) {
		// TODO Auto-generated method stub
		ideasDao.update(ideasEntity);
	}

	@Override
	public void delete(Long id) {
		// TODO Auto-generated method stub
		ideasDao.delete(id);
	}

	@Override
	public void deleteBatch(Integer[] ids) {
		// TODO Auto-generated method stub
		ideasDao.deleteBatch(ids);
	}

	@Override
	public List<IdeaEntity> queryForList(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return ideasDao.queryForList(map);
	}

	@Override
	public List<IdeaEntity> queryForIdeaList(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return ideasDao.queryForIdeaList(map);
	}

	@Override
	public String exportCreateCreativeCSV(List<String> ids) {
		// TODO Auto-generated method stub
		StringBuffer sb = new StringBuffer();
		sb.append("创意标题,创意描述1,创意描述2,创意默认显示url,创意默认访问url,启用/暂停,设备偏好\n");
		List<IdeaEntity> ideaList = ideasDao.exportCreateCreativeCSV(ids);
		if(!ideaList.isEmpty()){
			for(IdeaEntity i : ideaList){
				sb.append(i.toCSVString()).append("\n");
			}
			return sb.toString();
		}
		
		return "";
	}

	@Override
	public List<IdeaHelp> queryIdea(String keyword) {
		// TODO Auto-generated method stub
		return ideasDao.queryIdea(keyword);
	}

	@Override
	public List<IdeaHelp> queryUnitIdea(String keyword) {
		// TODO Auto-generated method stub
		return ideasDao.queryUnitIdea(keyword);
	}

	@Override
	public Long[] queryForIdeaListById(Integer[] ids) {
		// TODO Auto-generated method stub
		return ideasDao.queryForIdeaListById(ids);
	}
	
	@Override
	public void updateBatch(List<IdeaEntity> ideas) {
		// TODO Auto-generated method stub
		ideasDao.updateBatch(ideas);
	}
	
	@Override
	public List<Long> uploadIdea(Long accountId) {
		// TODO Auto-generated method stub
		return ideasDao.uploadIdea(accountId);
	}
	
	@Override
	public void deleteBatchByCreateId(List<Long> creativeIds) {
		// TODO Auto-generated method stub
		ideasDao.deleteBatchByCreateId(creativeIds);
	}

}
